package com.gitee.cheungming.order.controller;

import com.gitee.cheungming.common.Result;
import com.gitee.cheungming.order.dto.OrderRequest;
import com.gitee.cheungming.order.model.Order;
import com.gitee.cheungming.order.service.IOrderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author Zhang Ming
 * @since 2025-10-28
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    IOrderService orderService;

    @RequestMapping("/create")
    public Result<Long> createOrder(@RequestBody OrderRequest request) {
        Long orderId = orderService.createOrder(request);
        return Result.success(orderId);
    }

    @RequestMapping("/list")
    public Result<List<Order>> list() {
        List<Order> list = orderService.list();
        return Result.success(list);
    }
}
